package com.lame.sbconstant.product.strategy;

import com.lame.detect.vo.ClassMeta;
import com.lame.sbconstant.product.vo.ProductDesc;
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.tree.ParseTree;

/**
 * 生成常量类
 * */
public class DfConstantStrategy extends ProductActorAdapter {

    private String tpl = "${PACKAGE}.constant;\n" +
            "\n" +
            "public class ${ENTITY}Constant {\n" +
            "    //命名空间\n" +
            "    <#list fields as field >\n" +
            "    public static final String ${field.upHumpName} = \"${field.humpName}\" ;\n" +
            "    </#list>\n" +
            "}\n";

    @Override
    public String product(Parser parser, ParseTree parseTree, ClassMeta classMeta) {
        return TplTools.generate(classMeta, tpl);
    }

    @Override
    public ProductDesc productDesc(Parser parser, ParseTree parseTree, ClassMeta classMeta) {
        final String generate = TplTools.generate(classMeta, tpl);
        return new ProductDesc("./constant/" + classMeta.getName() + "Constant.java", generate, true);
    }
}
